{{Extend "layout"}}
{{Block "title"}}{{"指令管理"|T}}{{/Block}}
{{Block "breadcrumb"}}
{{Super}}
<li class="active">{{"指令管理"|T}}</li>
{{/Block}}
{{Block "main"}}
<div class="row">
	<div class="col-md-12">
		<div class="block-flat">
			<div class="header">
				<a href="__BACKEND__/manager/command_add" class="btn btn-success pull-right">
					<i class="fa fa-plus"></i>
					{{"添加指令"|T}}
				</a>
				<h3>{{"指令列表"|T}}</h3>
			</div>
			<div class="content">
				<div class="table-responsive">
				<table class="table no-border hover">
					<thead class="no-border">
						<tr>
							<th style="width:2%;"><strong>ID</strong></th>
							<th><strong>{{"名称"|T}}</strong></th>
							<th><strong>{{"命令"|T}}</strong></th>
							<th style="width:100px"><strong>{{"类型"|T}}</strong></th>
							<th><strong>{{"说明"|T}}</strong></th>
							<th style="width:65px"><strong>{{"状态"|T}}</strong></th>
							<th style="width:150px" class="text-center"><strong>{{"操作"|T}}</strong></th>
						</tr>
					</thead>
					<tbody class="no-border-y">
                        {{range $k,$v := Stored.listData}}
						<tr>
							<td>{{$v.Id}}</td>
							<td>{{$v.Name}}</td>
							<td>{{$v.Command}}</td>
							<td>
								{{- if eq $v.Remote "Y" -}}
								<span class="text-primary"><i class="fa fa-cloud"></i>{{"远程命令"|T}}</span>
								{{- else -}}
								<span class="text-success"><i class="fa fa- fa-desktop"></i>{{"本地命令"|T}}</span>
								{{- end -}}
							</td>
							<td>{{$v.Description}}</td>
							<td>
								<div class="checkbox checkbox-success no-margin-y">
									<input id="checkbox-{{$k}}" class="styled switch-disabled" type="checkbox" data-id="{{$v.Id}}" data-disabled="{{$v.Disabled}}"{{if eq $v.Disabled "N"}} checked="checked"{{end}} value="N" /><label for="checkbox-{{$k}}">{{"启用"|T}}</label>
								</div>
							</td>
							<td class="text-center">
							<a class="label label-danger" href="__BACKEND__/server/cmd?id={{$v.Id}}" data-toggle="tooltip" title="{{"执行"|T}}"><i class="fa fa-play"></i></a>
							<a class="label label-default" href="__BACKEND__/manager/command_add?copyId={{$v.Id}}" title="{{"复制"|T}}"><i class="fa fa-copy"></i></a>
							<a class="label label-success" href="__BACKEND__/manager/command_edit?id={{$v.Id}}"><i class="fa fa-pencil"></i></a> 
							<a class="label label-danger" href="__BACKEND__/manager/command_delete?id={{$v.Id}}" onclick="return confirm('{{"真的要删除吗？"|T}}');"><i class="fa fa-times"></i></a>
							</td>
						</tr>
                        {{end}}
					</tbody>
				</table>
				</div>
				{{Stored.pagination.Render}}
			</div>
		</div>
	</div>
</div>
{{/Block}}
{{Block "footer"}}
<script>
$(function(){
	$('input.switch-disabled').on('click',function(r){
		var that=$(this),disabled=that.data('disabled')=='Y'?'N':'Y';
		$.get(BACKEND_URL+'/manager/command_edit',{
			disabled:disabled,
			id:that.data('id')
		},function(r){
			if(r.Code==1){
				that.data('disabled',disabled);
				that.prop('checked',disabled=='N');
			}
			App.message({title:'{{"系统消息"|T}}',text:r.Info,time:5000,sticky:false,class_name:r.Code==1?'success':'error'});
		},'json');
	});
});
</script>
{{/Block}}